Fedora 21
Sponsored Link

Docker : Add Images
2015/01/03
 
Add Images for container.
[1] For exmaple, update official image with installing httpd and add it as a new image for container. The container is generated every time for executing "docker run" command, so add the latest executed container like follows.
# display images

[root@dlp ~]#
docker images

REPOSITORY    TAG      IMAGE ID        CREATED       VIRTUAL SIZE
fedora        latest   834629358fe2    4 days ago    250.2 MB

# start a Container and install httpd

[root@dlp ~]#
docker run fedora /bin/bash -c "yum -y update; yum -y install httpd"

[root@dlp ~]#
docker ps -a | head -2

CONTAINER ID IMAGE         COMMAND               CREATED            STATUS                     PORTS   NAMES
d2ce2e1f4520 fedora:latest "/bin/bash -c 'yum -  About a minute ago Exited (0) 15 seconds ago  jovial_rosalind

# add the Image

[root@dlp ~]#
docker commit d2ce2e1f4520 my_image/fedora_httpd

7c0a9607663b3d3e890b4b279146294dadf14620a906e43426e48f9ef9bea6d0
# display images

[root@dlp ~]#
docker images

REPOSITORY              TAG        IMAGE ID       CREATED          VIRTUAL SIZE
my_image/fedora_httpd   latest     7c0a9607663b   8 seconds ago    484.2 MB
fedora                  latest     834629358fe2   4 days ago       250.2 MB

# Generate a Container from the new image and execute which command to make sure httpd exists

[root@dlp ~]#
docker run my_image/fedora_httpd /usr/bin/which httpd

/usr/sbin/httpd
 
Tweet